﻿Imports QueComer

Public Class NuevoRestaurantForm

    Public GestionRestauranteForm As GestionRestauranteForm

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click

    End Sub

    Private Sub btnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuardar.Click
        Dim negocio As New Gestion_Rest
        Dim name = Me.nombrei.Text
        Dim food = Me.tipo_comidai.Text
        Dim dist = Me.distritoi.Text
        Dim addr = Me.direccioni.Text
        Dim ruk = Me.ruci.Text

        Try
            If lblId.Text <> "" Then
                negocio.actualizar(name, food, dist, addr, ruk, lblId.Text)
            Else
                negocio.insertar(name, food, dist, addr, ruk)
            End If

            Me.GestionRestauranteForm.dgvplop.DataSource = ""

            Me.Close()
        Catch ex As Exception
            lblMensaje.Text = "Hubo un error al guardar"
        End Try
    End Sub

    Private Sub NuevoRestaurantForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If lblId.Text <> "" Then
            Dim negocio As New Gestion_Rest
            Dim modelo = negocio.obtener(lblId.Text)
            nombrei.Text = modelo.nombre
            tipo_comidai.Text = modelo.tipo_comida
            distritoi.Text = modelo.distrito
            direccioni.Text = modelo.direccion
            ruci.Text = modelo.ruc
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub
End Class